// =============================================================
// CService class
// ---------------------------------------
// Author : Woo-Hyun Kim
// Email : woorung@icu.ac.kr or woorung@nhncorp.com
// Date : Aug. 30, 2007
// =============================================================
#ifndef CServiceH
#define CServiceH
//-----------------------------------------------------------------
#include <iostream>
#include <iterator>
#include <string>
#include <map>
#include <vector>

#include "soap/baseCFactoryService.h"
#include "space/CSpace.h" // for CObject

using namespace std;
using namespace base;

// ----------------------------------------------------------------------
// Class for User Service
// ----------------------------------------------------------------------
class CService : public CObject
{
private:
	static long id;

	string name;
	string iname; // instance name for uniqueness

protected:
	struct soap *soap;

	// it will be implemented in the sub-classses
	virtual bool blindlyEquals(const CObject *rhs) const;
	virtual const type_info *getTypeEquiv() const;

public:
        CService();
        CService(char *name);
	// copy constructor
	CService(const CService &rhs);
        virtual ~CService();

	// clone
	virtual CService *clone() const;
	// create new instance
	virtual CService *newInstance() const;
	// assign constructor
	virtual CService &operator=(const CService &rhs);

        void setName(char *name);
        char *getName() const;

	void instance(char *iname);
	char *instance() const;

	// make request
	int parameterize(cube__CObject *in, map<string,string> &keyval);
	// sort & make response
	int incarnate(struct cube__invokeResponse &res, map<string,string> &keyval);

	// internal service invocation
	void execute(struct soap *soap, cube__CObject *in, struct cube__invokeResponse &res);
	// it must be implemented in real services
        virtual void run(cube__CObject *in, struct cube__invokeResponse &res);
};
#endif
